<?php

namespace App\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Redis;

class House extends Model
{
	use HasDateTimeFormatter;
    use SoftDeletes;

    protected $table = 'house';
    //取出所有房源数据
    public function HouseData(){
        $houseData = self::all()->toArray();
        foreach ($houseData as $k => $v){
            Redis::hset("SKXhouseData",$v['id'],json_encode($v));
        }
        return $houseData;
    }

    //批量取出指定房源列表
    public function getHouseLise($list){
        $houseList = self::wherein('id',$list)->get();
        return $houseList;
    }

    public function setHouseConfigAttribute($value)
    {
        $this->attributes['house_config'] = implode(',',$value);
    }

    public function setHouseLabelAttribute($value)
    {
        $this->attributes['house_label'] = implode(',',$value);
    }






}
